/**
 * 生产模块API接口
 * 包含生产计划、生产任务、生产统计等相关接口
 */

import { http } from '@/common/service/service.js'

// 生产计划相关接口
const productionPlan = {
  // 获取生产计划列表
  getList(params = {}) {
    return http.get('/mes/production/plan/list', params)
  },

  // 获取生产计划详情
  getDetail(id) {
    return http.get(`/mes/production/plan/detail/${id}`)
  },

  // 创建生产计划
  create(data) {
    return http.post('/mes/production/plan/create', data)
  },

  // 更新生产计划
  update(id, data) {
    return http.put(`/mes/production/plan/update/${id}`, data)
  },

  // 删除生产计划
  delete(id) {
    return http.delete(`/mes/production/plan/delete/${id}`)
  },

  // 启动生产计划
  start(id) {
    return http.post(`/mes/production/plan/start/${id}`)
  },

  // 暂停生产计划
  pause(id) {
    return http.post(`/mes/production/plan/pause/${id}`)
  },

  // 完成生产计划
  complete(id) {
    return http.post(`/mes/production/plan/complete/${id}`)
  }
}

// 生产任务相关接口
const productionTask = {
  // 获取生产任务列表
  getList(params = {}) {
    return http.get('/mes/production/task/list', params)
  },

  // 获取生产任务详情
  getDetail(id) {
    return http.get(`/mes/production/task/detail/${id}`)
  },

  // 创建生产任务
  create(data) {
    return http.post('/mes/production/task/create', data)
  },

  // 分配任务
  assign(id, data) {
    return http.post(`/mes/production/task/assign/${id}`, data)
  },

  // 开始任务
  start(id) {
    return http.post(`/mes/production/task/start/${id}`)
  },

  // 暂停任务
  pause(id) {
    return http.post(`/mes/production/task/pause/${id}`)
  },

  // 完成任务
  complete(id, data) {
    return http.post(`/mes/production/task/complete/${id}`, data)
  },

  // 获取我的任务
  getMyTasks(params = {}) {
    return http.get('/mes/production/task/my-tasks', params)
  }
}

// 生产统计相关接口
const productionStats = {
  // 获取生产概览统计
  getOverview(params = {}) {
    return http.get('/mes/production/stats/overview', params)
  },

  // 获取生产效率统计
  getEfficiency(params = {}) {
    return http.get('/mes/production/stats/efficiency', params)
  },

  // 获取员工绩效统计
  getEmployeePerformance(params = {}) {
    return http.get('/mes/production/stats/employee-performance', params)
  },

  // 获取设备利用率统计
  getEquipmentUtilization(params = {}) {
    return http.get('/mes/production/stats/equipment-utilization', params)
  }
}

export { productionPlan, productionTask, productionStats }
